/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.tianji.jersey.resource.json;

import java.util.Date;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 *
 * @author kanghui
 */
@Path("/json")
public class JsonResource {
    private Log log = LogFactory.getLog(this.getClass());
    private static String t1 = "http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/image/tests/images/extraWide.jpg";
    private static String t2 = "http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/image/tests/images/imageHoriz.jpg";
    private static String t3 = "http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/image/tests/images/imageHoriz2.jpg";
    private static String t4 = "http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/image/tests/images/imageVert.jpg";
    private static String t5 = "http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/image/tests/images/square.jpg";
    private static String t6 = "http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/image/tests/images/extraWide.jpg";
    private static String t7 = "http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/image/tests/images/imageHoriz.jpg";
    private static String t8 = "http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/image/tests/images/imageHoriz2.jpg";
    private static String t9 = "http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/image/tests/images/imageVert.jpg";
    private static String t0 = "http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/image/tests/images/square.jpg";
    private static String[] pics = new String[]{t0,t1,t2,t3,t4,t5,t6,t7,t8,t9};
     @Path("{id}")
	 @GET
	 @Produces("application/json")
     public PreviewPicList getSubResource(@Context UriInfo uriInfo,@PathParam("id") int id) {
    	 
		 System.out.println("-------------------------------------------------------");
		
		 return this.getList(id);
     }
     private PreviewPicList getList(int size) {
    	 PreviewPicList picItems = new PreviewPicList();
		for (int i = 0; i < size; i++) {
			PreviewPicItem item = new PreviewPicItem();
			item.setCreateTime(new Date());
			item.setDesc("desc"+i);
			item.setLarge(pics[i]);
			item.setMini(pics[i]);
			item.setPicId(i);
			item.setUserId(4603573);
			
			picItems.getItems().add(item);

		}
		return picItems;
	}
}
